import request from '../utils/request'

export const list = () => request({
    method: 'get',
    url: '/api/articles'
})

export const feed = () => request({
    method: 'get',
    url: '/api/articles/feed'
})

export const get = (slug) => request({
    method: 'get',
    url: `/api/articles/${slug}`
})

export const create = article => request({
    method: 'post',
    url: '/api/articles',
    data: {
        article
    }
})

export const update = (slug, article) => request({
    method: 'put',
    url: `/api/articles/${slug}`,
    data: {
        article
    }
})

export const del = slug => request({
    method: 'delete',
    url: `/api/articles/${slug}`
})

export const favorite = slug => request({
    method: 'post',
    url: `/api/articles/${slug}/favorite`
})

export const unfavorite  = slug => request({
    method: 'delete',
    url: `/api/articles/${slug}/favorite`
})